home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/perl
-
- # Sort file.pl
- # This script sorts lines of a file
- #
- # 12/22/95 Version 1.0
- # This script is free, public domain, no strings attached.
- # Igor Livshits <igorl@uiuc.edu>
- #
- # Caveat: MacPerl will require much memory to sort large files: 3MB for InfoMac
-
-
- $openToWrite= "> ";
- $macPathDelimiter= ":";
-
- # Read in the arguments passed to us from the AppleScript agent
- #
- $workingDirectory= $ARGV[$argumentCounter++] . $macPathDelimiter;
- $aFile= $ARGV[$argumentCounter++];
-
-
- # Read the file into an array
- #
- open(aFile, $workingDirectory . $aFile) || die "Cannot open $aFile: $!";
- @anArray= <aFile>; # read our file, line by line, into array elements
- close(aFile);
-
-
- # Dump the sorted array into our file
- #
- open(aFile, $openToWrite . $workingDirectory . $aFile) || die "Cannot open $aFile: $!";
- print (aFile (sort (@anArray)));
- close(aFile);
-